package gui;
/**
 * The Display class sets up the basic format for all JFrame elements
 * in the program. It keeps such things as default close operation and 
 * JFrame text consistent between all windows.
 */
import java.awt.CardLayout;
import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class Display {
	protected JFrame frame;	
	
	/**
	 * Constructor initialises a new Display; sets text value, foreground and
	 * background colours, layout, bounds and exit conditions
	 */
	public Display() {
		frame = new JFrame("A 5-CARD STUD GAME CREATED BY 5 STUDS");
		frame.setVisible(false);
		
		frame.setBackground(Color.WHITE);
		frame.getContentPane().setBackground(Color.BLACK);
		frame.getContentPane().setLayout(new CardLayout(0, 0));
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setBounds(100, 100, 645, 527);
	}
	
	// Getters and setters:
	
	public void setFrame(JFrame f) {
		frame = f;
	}
	
	public JFrame getFrame() {
		return frame;
	}
	
	/**
	 * Adds a new JFrame element to an existing display
	 * @param frame JFrame to be added to the display
	 */
	public Display(JFrame frame) {
		this.frame = frame;
		
		frame.setBackground(Color.WHITE);
		frame.getContentPane().setBackground(Color.BLACK);
		frame.getContentPane().setLayout(new CardLayout(0, 0));
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setBounds(100, 100, 645, 527);
	}
	
	/**
	 * Displays an error message as a popup
	 * @param message String to be shown in popup
	 */
	public void showError(String message) {
		JOptionPane.showMessageDialog(frame, message);
	}
}
